﻿<Window x:Class="RL.wVehicleTypeItem"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Модель транспортного средства" Height="393" Width="488" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:my="clr-namespace:RL" Loaded="Window_Loaded" Closing="Window_Closing">
    <Window.Resources>
        <!--<XmlDataProvider x:Key="type_vehicle1" XPath="Typevehicle/Types" >
            <x:XData>
                <Typevehicle xmlns="">
                    <Types>
                        <Type id="1" name="автобус" />
                        <Type id="2" name="грузовой автомобиль" />
                        <Type id="3" name="легковой автомобиль" />
                    </Types>
                </Typevehicle>
            </x:XData>
        </XmlDataProvider>-->
        <CollectionViewSource x:Key="VehicletypeFuelSource" />
        <CollectionViewSource x:Key="FuelTypeSource" />
        <my:vehicle_type x:Key="vehicle_typeViewSource"  />
       <CollectionViewSource x:Key="vehicle_typeViewSource1" d:DesignSource="{d:DesignInstance my:vehicle_type, CreateList=True}" />
        <CollectionViewSource x:Key="vehicle_typeFuelVehicleTypeNormViewSource" Source="{Binding Path=FuelVehicleTypeNorm, Source={StaticResource vehicle_typeViewSource1}}" />
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Name="stackPanel1" Orientation="Horizontal" />
        <Button Content="OK" Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="buttonSave" VerticalAlignment="Top" Width="75" Click="buttonSave_Click"/>
        <TabControl Grid.Row="1" Name="tabControl1">
            <TabItem Header="Основная" Name="tabItemMain">
                <Grid>
                    <Grid.Resources>

                    </Grid.Resources>
                    <Grid DataContext="{StaticResource vehicle_typeViewSource}" HorizontalAlignment="Left" Margin="12,9,0,0" Name="grid1" VerticalAlignment="Top" Width="350">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Label Content="Код:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <TextBlock Grid.Column="1" Height="23" HorizontalAlignment="Left" Margin="2,3,0,3" Name="idTextBlock" Text="{Binding Path=id}" VerticalAlignment="Center" />
                        <Label Content="Наименование:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <TextBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="2,3,0,3" Name="nameTextBox" Text="{Binding Path=name, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="200" />
                        <Label Content="Топливо:" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <!--<TextBox Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="3,3,0,3" Name="id_main_fuel_typeTextBox" Text="{Binding Path=id_main_fuel_type, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="201" TextChanged="id_main_fuel_typeTextBox_TextChanged" />-->
                        <!--<my:ucFuelType Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="2,3,0,3" x:Name="id_main_fuel_typeTextBox" FuelType="{Binding Path=id_main_fuel_type, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="246" />-->
                        <my:ucFuelType Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="2,3,0,3" x:Name="id_main_fuel_typeTextBox" ItemsSource="{Binding Source={StaticResource FuelTypeSource}}" FuelType="{Binding Path=fuel_type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" Width="246" />
                        <Label Content="Вид ТС:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <ComboBox DisplayMemberPath="@name" SelectedValuePath="@id" Grid.Column="1" Grid.Row="3" Height="23" SelectedValue="{Binding Path=type_vehicle, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  HorizontalAlignment="Left" ItemsSource="{Binding XPath=*,Source={StaticResource type_vehicle1}}" Margin="2,3,0,3" Name="type_vehicleComboBox" VerticalAlignment="Center" Width="199" IsSynchronizedWithCurrentItem="False">
                            <ComboBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <VirtualizingStackPanel />
                                </ItemsPanelTemplate>
                                
                            </ComboBox.ItemsPanel>
                        </ComboBox>
                        <Label Content="Расх. нагр.:" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <TextBox Grid.Column="1" Grid.Row="4" Height="23" HorizontalAlignment="Left" Margin="2,3,0,3" Name="heaterTextBox" Text="{Binding Path=heater, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="199" />
                        <Label Content="Кол-во мест:" Grid.Column="0" Grid.Row="5" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <TextBox Grid.Column="1" Grid.Row="5" Height="23" HorizontalAlignment="Left" Margin="2,3,0,3" Name="passTextBox" Text="{Binding Path=qnt_passenger, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="199" />
                        <Label Content="Всего мест:" Grid.Column="0" Grid.Row="6" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <TextBox Grid.Column="1" Grid.Row="6" Height="23" HorizontalAlignment="Left" Margin="2,3,0,3" Name="totpassTextBox" Text="{Binding Path=qnt_total_passenger, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="199" />

                        <Label Content="Выкл:" Grid.Column="0" Grid.Row="7" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <CheckBox Content="" Grid.Column="1" Grid.Row="7" Height="16" HorizontalAlignment="Left" IsChecked="{Binding Path=del, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Margin="2,3,0,3" Name="delCheckBox" VerticalAlignment="Center" />
                    </Grid>
                </Grid>
            </TabItem>
            <TabItem Header="Топливо" Name="tabItemCharact">
                <Grid DataContext="{StaticResource vehicle_typeFuelVehicleTypeNormViewSource}">
                    <Grid.Resources>
                        <my:FuelTypeConverter x:Key="FuelTypeConverter" />
                        <DataTemplate x:Key="fuelType">
                            <my:ucFuelType FuelTypeID="{Binding Path=id_type_fuel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                        </DataTemplate>
                        <DataTemplate x:Key="fuelTypeView">
                            <TextBlock Text="{Binding Path=id_fuel_type, Mode=TwoWay, Converter={StaticResource FuelTypeConverter}}"/>
                        </DataTemplate>
                    </Grid.Resources>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="35"/>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding}" Name="fuelVehicleTypeNormDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" Grid.Row="1" CanUserAddRows="True">
                        <DataGrid.Columns>
                            <!--<DataGridTextColumn x:Name="idColumn" Binding="{Binding Path=id}" Header="id" Width="SizeToHeader" />-->
                            <DataGridTemplateColumn Header="Топливо" CellTemplate="{StaticResource fuelType}" CellEditingTemplate="{StaticResource fuelType}" />
                            <!--<DataGridTemplateColumn Width="210" Header="Топливо">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <my:ucFuelType FuelTypeID="{Binding Path=id_fuel_type, Mode=TwoWay}"/>                                
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>-->
                            <!--<DataGridTextColumn x:Name="id_type_fuelColumn" Binding="{Binding Path=id_type_fuel}" Header="id type fuel" Width="SizeToHeader" />-->
                            <DataGridTextColumn x:Name="expense_normColumn" Binding="{Binding Path=expense_norm}" Header="Расход (л/100км)" Width="SizeToHeader" />
                        </DataGrid.Columns>
                    </DataGrid>
                    <StackPanel Name="stackPanel2" Orientation="Horizontal">
                        <Button Content="Добавить" Height="23" Name="buttonAdd" Width="75" Click="buttonAdd_Click"/>
                        <Button Content="Удалить" Height="23" Name="buttonDelete" Width="75" Click="buttonDelete_Click"/>
                    </StackPanel>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
